package com.weijian.controller.admin;


import com.weijian.common.pojo.CommonResult;
import com.weijian.dal.vo.BusinessDataVO;
import com.weijian.dal.vo.DishOverViewVO;
import com.weijian.dal.vo.OrderOverViewVO;
import com.weijian.dal.vo.SetmealOverViewVO;
import com.weijian.service.WorkspaceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/workspace")
@Slf4j
@Schema(description = "工作台相关接口")
@RequiredArgsConstructor
public class WorkSpaceController {

    final WorkspaceService workspaceService;

    /**
     * 工作台今日数据查询
     *
     * @return
     */
    @GetMapping("/businessData")
    @Schema(description = "工作台今日数据查询")
    public CommonResult<BusinessDataVO> businessData() {
        //获得当天的开始时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        //获得当天的结束时间
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin, end);
        return CommonResult.success(businessDataVO);
    }

    @GetMapping("/overview")
    @Operation(description = "付款订单总览")
    public CommonResult<OrderOverViewVO> getOrderOverView() {
        OrderOverViewVO orderOverViewVO = workspaceService.getOrderOverView();
        return CommonResult.success(orderOverViewVO);
    }

    @Operation(summary = "查询菜品总览")
    @GetMapping("/overviewDishes")
    public CommonResult<DishOverViewVO> getDishOverView() {
        return workspaceService.getDishOverView();
    }

    @Operation(summary = "查询套餐总览")
    @GetMapping("/overviewSetmeals")
    public CommonResult<SetmealOverViewVO> getSetMealOverView() {
        return workspaceService.getSetMealOverView();
    }

}
